<template>
  <view> </view>
</template>

<script>
import share from "@/common/share.js";
export default {
  data() {
    return {
      title: "Hello",
    };
  },
  onLoad() {},
  onBackPress() {
    //监听back键，关闭弹出菜单
    if (this.shareObj.shareMenu.isVisible()) {
      this.shareObj.shareMenu.hide();
      this.shareObj.alphaBg.hide();
      return true;
    }
  },
  methods: {
    shareInfo(shareInfo) {
      let shareList = [
        {
          icon: "/static/images/sharemenu/wx.png",
          text: "微信好友",
        },
        {
          icon: "/static/images/sharemenu/pyq.png",
          text: "朋友圈",
        },
        // {
        // 	icon:"/static/images/sharemenu/weibo.png",
        // 	text:"微博"
        // },
        // {
        // 	icon:"/static/images/sharemenu/qq.png",
        // 	text:"QQ"
        // },
        // {
        // 	icon:"/static/images/sharemenu/copy.png",
        // 	text:"复制"
        // },
        // {
        // 	icon:"/static/images/sharemenu/more.png",
        // 	text:"更多"
        // },
      ];
      this.shareObj = share(shareInfo, shareList, function (index) {
        console.log("点击按钮的序号: " + index);
        let shareObj = {
          title: shareInfo.title || "",
          summary: shareInfo.desc || "",
          miniProgram: {
            id: "gh_a59daf7d0132",
            path: shareInfo.href,
            type: 2,
            webUrl: this.$share + "/#" + shareInfo.href,
          },
          success: (res) => {
            console.log("success:" + JSON.stringify(res));
          },
          fail: (err) => {
            console.log("fail:" + JSON.stringify(err));
          },
        };
        console.log("11111111111", shareInfo);
        switch (index) {
          case 0:
            shareObj.provider = "weixin";
            shareObj.scene = "WXSceneSession";
            shareObj.type = 5;
            shareObj.imageUrl = shareInfo.imgUrl || "";
            console.log("微信分享", shareObj);
            uni.share(shareObj);
            break;
          case 1:
            shareObj.provider = "weixin";
            shareObj.scene = "uniSenceTimeline";
            shareObj.type = 5;
            shareObj.imageUrl = shareInfo.imgUrl || "";
            uni.share(shareObj);
            break;
          // case 2:
          // 	shareObj.provider="sinaweibo";
          // 	shareObj.type=0;
          // 	shareObj.imageUrl=shareInfo.imgUrl||"";
          // 	uni.share(shareObj);
          // 	break;
          // case 2:
          // 	shareObj.provider="qq";
          // 	shareObj.type=5;
          // 	shareObj.imageUrl=shareInfo.imgUrl||"/static/images/sharemenu/qq.png";
          // 	uni.share(shareObj);
          // 	console.log('shareObj=',JSON.stringify(shareObj))
          // 	break;
          // case 2:
          // 	uni.setClipboardData({
          // 		data:this.$share + '/#'+shareInfo.href,
          // 		complete() {
          // 			uni.showToast({
          // 				title: "链接已复制到剪贴板",
          // 				icon:"none"
          // 			})
          // 		}
          // 	})
          // 	break;
          // case 2:
          // 	plus.share.sendWithSystem({
          // 		type:"web",
          // 		title:shareInfo.title||"",
          // 		thumbs:[shareInfo.imgUrl||""],
          // 		href:'https://uriwin.com/store/index.php?act=goods&op=index&goods_id='+shareInfo.goods_id||"",
          // 		content: shareInfo.desc||"",
          // 	})
          // 	break;
        }
      });
      this.$nextTick(() => {
        this.shareObj.alphaBg.show();
        this.shareObj.shareMenu.show();
      });
    },
  },
};
</script>

<style>
</style>
